package cn.itsource.zcn.user.mapper;

import cn.itsource.zcn.user.domain.UserAddress;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * 订单地址(UserAddress)表数据库访问层
 *
 * @author makejava
 * @since 2021-08-26 16:04:33
 */
public interface UserAddressMapper {

    /**
     * 新增数据
     *
     * @param tUserAddress 实例对象
     */
    @Insert("insert into t_user_address" +
            "(createTime,updateTime,contacts,areaCode,address,user_id,fullAddress,phone,phoneBack,tel,postCode,email)" +
            "values (#{createTime},#{updateTime},#{contacts},#{areaCode},#{address},#{user_id},#{fullAddress},#{phone},#{phoneBack},#{tel},#{postCode},#{email})")
    void save(UserAddress tUserAddress);

    /**
     * 修改数据
     *
     * @param tUserAddress 实例对象
     */
    @Update("update t_user_address set " +
            "createTime=#{createTime},updateTime=#{updateTime},contacts=#{contacts},areaCode=#{areaCode},address=#{address},user_id=#{user_id},fullAddress=#{fullAddress},phone=#{phone},phoneBack=#{phoneBack},tel=#{tel},postCode=#{postCode},email=#{email} " +
            "where id = #{id}")
    void update(UserAddress tUserAddress);

    /**
     * 通过主键删除数据
     *
     * @param id 主键
     */
    @Delete("delete from t_user_address where id = #{id} ")
    void delete(Long id);


    /**
     * 通过ID查询单条数据
     *
     * @param id 主键
     * @return 实例对象
     */
    @Select("select * from t_user_address where id = #{id}")
    UserAddress queryById(Long id);

    /**
     * 查询全部
     *
     * @return 对象列表
     */
    @Select("select * from t_user_address")
    List<UserAddress> queryAll();

    /**
     * 批量新增数据（MyBatis原生foreach方法）
     *
     * @param entities List<UserAddress> 实例对象列表
     */
    void insertBatch(@Param("UserAddresss") List<UserAddress> entities);

    /**
     * 批量删除数据（MyBatis原生foreach方法）
     *
     * @param ids List<Integer> 实例对象列表
     */
    void deleteBatch(@Param("ids") List<Integer> ids);


}

